package org.testmyapp.tasks;

import java.util.List;
import java.util.Map;

import org.testmyapp.engine.IEngineServices;
import org.testmyapp.entities.Bill;
import org.testmyapp.global.Variable;
import org.testmyapp.persistence.BusinessObjectPersistenceProvider;

public class CheckBills implements TaskWorker {

	public String validate(IEngineServices aes,
			Map<String, String[]> parameterMap, String processInstanceId,
			BusinessObjectPersistenceProvider bopp) {
		String key = "actionPruefung";
		String actionPruefung = parameterMap.get(key)[0];
		if(actionPruefung != null && actionPruefung.equals("endErfassung")) {
			//since there is no multiple in multiple we have to create one our own
			@SuppressWarnings("unchecked")
			List<Bill> billList = (List<Bill>) aes.getVariable(Variable.BILLLIST.getName(), processInstanceId);
//			aes.setVariable(processInstanceId, "amountBills", billList.size());
//			aes.setVariable(processInstanceId, "countBills", new Integer(0));
//			aes.setVariable(processInstanceId, "countBillsCalc", new Integer(0));
		}
		aes.setVariable(processInstanceId, key, actionPruefung);
		return "";
	}

}
